﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using Medianamik.Core.Logging;

namespace Medianamik.Core.Redirect
{
    public class RedirectNode : SystemNode<RedirectNode>, IRedirectNode
    {
        public override Guid SystemNodeTypeID
        {
            get { return MedianamikTypes.MedianamikRedirect; }
        }

        public override Guid NamePropertyId
        {
            get
            {
                return MedianamikProperties.MedianamikRedirectFrom;
            }
        }

        public override Guid NodeTypeID
        {
            get
            {
                return SystemNodeTypeID;
            }
        }

        public string RedirectFrom
        {
            get
            {
                return DefaultInstance[MedianamikProperties.MedianamikRedirectFrom].GetValue<string>();
            }
        }

        public string RedirectTo
        {
            get { return NodeType.LocalizedName + " -> " + DisplayName; }
        }

        public Guid RedirectToNodeId
        {
            get
            {
                return DefaultInstance[MedianamikProperties.MedianamikRedirectTo].GetValue<Guid>();
            }

        }

        public Node RedirectToNode
        {
            get
            {
                return NodeManager.GetNode(RedirectToNodeId);
            }
        }

        public int ResponseCode
        {
            get
            {
                return DefaultInstance[MedianamikProperties.MedianamikRedirectCode].GetValue<int>();
            }
        }

        public string QueryString
        {
            get
            {
                return DefaultInstance[MedianamikProperties.MedianamikRedirectQS].GetValue<string>();
            }
        }
    }

    public interface IRedirectNode
    {
        string RedirectFrom { get; }
        int ResponseCode { get; }
        string RedirectTo { get; }
    }
}
